//
//  HEIMConsulReportCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/12/7.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEIMConsulReportCell.h"

@interface HEIMConsulReportCell ()

@property(nonatomic, strong) UILabel *textLb;

@end

@implementation HEIMConsulReportCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
   if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
       
       self.selectionStyle = UITableViewCellSelectionStyleNone;
 
       [self initUI];
       [self makeGesture];
   }
   return self;
}

- (void)makeGesture {
    UITapGestureRecognizer *contentTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(contentClick)];
    [self.bubbleView addGestureRecognizer: contentTap];
}

- (void)contentClick {
    if ([self.delegate respondsToSelector:@selector(onTapMessage:)]) {
        [self.delegate onTapMessage: self.model.message];
    }
}

- (void)initUI {
    
    UILabel *titleLb = [UILabel new];
    titleLb.text = @"咨询报告：";
    titleLb.font = DYBlodFont(16);
    titleLb.numberOfLines = 0;
    titleLb.textColor = KWhiteColor;
    [self.bubbleView addSubview: titleLb];
    
    UIView *repWarp = [UIView new];
    repWarp.backgroundColor = KWhiteColor;
    [self.bubbleView addSubview: repWarp];
    repWarp.layer.cornerRadius = 5;
    repWarp.layer.masksToBounds = YES;

 
    _textLb = [UILabel new];
    _textLb.text = @"咨询报告：但是咋端";
    _textLb.font = DYFont(16);
    _textLb.numberOfLines = 0;
    _textLb.textColor = KBlackColor;
    [repWarp addSubview: _textLb];
    [_textLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    UILabel *noticeLb = [UILabel new];
    noticeLb.text = @"点击查看报告内容>>";
    noticeLb.font = DYFont(14);
    noticeLb.textColor = CNavDargGrayColor;
    [repWarp addSubview: noticeLb];
    
    [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bubbleView).mas_offset(10);
        make.left.equalTo(self.bubbleView).mas_offset(10);
        make.right.equalTo(self.bubbleView).mas_offset(-10);
    }];
    
    [repWarp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLb.mas_bottom).mas_offset(10);
        make.left.equalTo(self.bubbleView).mas_offset(10);
        make.right.equalTo(self.bubbleView).mas_offset(-10);
        make.bottom.equalTo(self.bubbleView).mas_offset(-10);
    }];
    
    [_textLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(repWarp).mas_offset(10);
        make.left.equalTo(repWarp).mas_offset(5);
        make.right.equalTo(repWarp).mas_offset(-5);
    }];
    
   [noticeLb mas_makeConstraints:^(MASConstraintMaker *make) {
       make.top.equalTo(_textLb.mas_bottom).mas_offset(10);
       make.left.equalTo(repWarp).mas_offset(5);
       make.right.equalTo(repWarp).mas_offset(-5);
       make.bottom.equalTo(repWarp).mas_offset(-10);
   }];
}

- (void)configCellWithModel:(HEIMMessageModel *)model {
   _textLb.text = [NSString stringWithFormat:@"咨询内容：%@", model.message.title];

   [_textLb mas_updateConstraints:^(MASConstraintMaker *make) {
       make.width.mas_offset(model.contentWidth);
   }];
   
   // 必须写
   [self refreshData:model];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
   [super setSelected:selected animated:animated];

   // Configure the view for the selected state
}

@end
